package Models;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Locale;

import Enums.POSTATE;


public class PurchaseOrder {
    private SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd", Locale.US);
    private int poID; //PurchaseOrder.POID
    private int poState; //PurchaseOrder.POState
    private Date poDate; //PurchaseOrder.PODate
    private boolean exported; // SalesOrder.exported
    private List<POLines> pos;
    
	public int getPoID() {
		return poID;
	}
	public void setPoID(int poID) {
		this.poID = poID;
	}
	public int getPoState() {
		return poState;
	}
	public void setPoState(int poState) {
		this.poState = poState;
	}
	public Date getPoDate() {
		return poDate;
	}
	public void setPoDate(Date poDate) {
		this.poDate = poDate;
	}
	public boolean isExported() {
		return exported;
	}
	public void setExported(boolean exported) {
		this.exported = exported;
	}
	public List<POLines> getPos() {
		return pos;
	}
	public void setPos(List<POLines> pos) {
		this.pos = pos;
	}
    
    public String getDisplayString(){
    	String vend = "";
    	if(this.pos!=null && pos.get(0)!=null && pos.get(0).getPoLinePartNumber()!=null
    			&& pos.get(0).getPoLinePartNumber().getVendorID()!=null){
    		vend = pos.get(0).getPoLinePartNumber().getVendorID().getVendorName();
    	}
        return Integer.toString(poID) + "(" 
        		+ POSTATE.getStateFromInt(this.poState).getDesc() + "):"+ vend + " - " 
        		+ dateFormat.format(poDate);
    }
    
    public String getSmallDisplayString(){
    	String vend = "Misc.";
    	if(this.pos!=null && pos.get(0)!=null && pos.get(0).getPoLinePartNumber()!=null
    			&& pos.get(0).getPoLinePartNumber().getVendorID()!=null){
    		vend = pos.get(0).getPoLinePartNumber().getVendorID().getVendorName();
    	}
        return Integer.toString(poID) + ": " +  vend;
    }
}
